<template>
  <div class="home">
    <!-- 导航 -->
    <div class="navBar">
      <navBar></navBar>
    </div>
    <!-- 主体 -->
    <div class="conten">
      <div class="adsForm">
        <h3 class="pageTitle">安全管理</h3>
        <!-- 链接广告 -->
        <el-form
          :model="ruleForm"
          :rules="rules"
          ref="ruleForm"
          label-width="150px"
          class="demo-ruleForm"
          :v-show="tabIndex === 0"
        >
          <!-- 姓名 -->
          <el-form-item label="姓名" prop="name">
            <el-input
              v-model="ruleForm.name"
              placeholder="请输入姓名"
              disabled="disabled"
            ></el-input>
          </el-form-item>
          <!-- 账号 -->
          <el-form-item label="账号" prop="name">
            <el-input
              v-model="ruleForm.name"
              placeholder="请输入账号"
              disabled="disabled"
            ></el-input>
          </el-form-item>

          <!-- 三级联动 -->
          <el-form-item label="地址" prop="region">
            <el-cascader
              size="large"
              :options="options_"
              v-model="selectedOptions"
              @change="handleChange"
              placeholder="请选择地址"
              class="longSelect"
              disabled="disabled"
            ></el-cascader>
          </el-form-item>
             <!-- 旧密码 -->
          <el-form-item label="旧密码" prop="name">
            <el-input
              v-model="ruleForm.name"
              placeholder="请输入旧密码"
            ></el-input>
          </el-form-item>
           <!-- 新密码 -->
          <el-form-item label="新密码" prop="name">
            <el-input
              v-model="ruleForm.name"
              placeholder="请输入新密码"
            ></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="submitForm('ruleForm')"
              >立即修改</el-button
            >
            <el-button @click="resetForm('ruleForm')">重置</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
    <!-- 底部 -->
    <div class="footerBar">
      <footBar></footBar>
    </div>

    <!-- 右侧分享按钮 -->
  </div>
</template>


<script>
// @ is an alias to /sr
import navBar from "../../components/header";
import footBar from "../../components/footer";
import {
  provinceAndCityData,
  regionData,
  provinceAndCityDataPlus,
  regionDataPlus,
  CodeToText,
  TextToCode,
} from "element-china-area-data";

export default {
  name: "security",
  components: {
    navBar,
    footBar,
  },
  data() {
    return {
      tabIndex: 0, //tab选项卡默认
      options_: regionData,
      selectedOptions: [],
      formInline: {
        user: "",
        region: "",
        lookTime: "",
      },
      imageUrl: "",
      ruleForm: {
        name: "",
        region: "",
        lookTime: "",
        delivery: false,
        text: `
        `,
      },
      rules: {
        name: [
          { required: true, message: "请输入活动名称", trigger: "blur" },
          { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" },
        ],
        region: [
          { required: true, message: "请选择活动区域", trigger: "change" },
        ],
      },
    };
  },
  methods: {
    // 表单提交
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert("submit!");
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    // 重置
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
    // 缩略图上传
    handleAvatarSuccess(res, file) {
      this.imageUrl = URL.createObjectURL(file.raw);
    },
    beforeAvatarUpload(file) {
      const isJPG = file.type === "image/jpeg";
      const isLt2M = file.size / 1024 / 1024 < 2;

      if (!isJPG) {
        this.$message.error("上传头像图片只能是 JPG 格式!");
      }
      if (!isLt2M) {
        this.$message.error("上传头像图片大小不能超过 2MB!");
      }
      return isJPG && isLt2M;
    },
    // 省市三级选择
    handleChange() {},
  },
};
</script>

<style scoped lang="less">
body,
htm {
  background-color: #999;
}

.footerBar {
  position: fixed;
  bottom: 0px;
  width: 100%;
}
.conten {
  padding-top: 60px;
  .pageTitle{
    font-size: 20px;
    color: #666;
    font-weight: bold;
    text-align: center;
    text-indent: 5em;
    margin: 20px 0px 30px 0px;
  }
  .dateInput{
    float: left;
  }
  > div {
    width: 600px;
    margin: 0 auto;
  }
  .unitStyle {
    color: cornflowerblue;
  }
  .tabBox {
    display: flex;
    justify-content: center;
    flex-wrap: nowrap;
    padding: 50px 0px 20px 0px;
    > div {
      font-size: 14px;
      font-weight: bold;
      color: #999;
      padding: 0 15px;
      height: 30px;
      line-height: 30px;
      cursor: pointer;
    }
    .active {
      background-color: #409eff;
      color: #fff;
    }
  }
  .backHome {
    font-size: 14px;
    color: #666;
    font-size: 14px;
    text-align: center;
    text-decoration: none;
  }
}

.longSelect {
  width: 100%;
}
</style>

<style lang="less">
body,
htm {
  background-color: #f5f5f5;
}
// 缩略图上传
.avatar-uploader .el-upload {
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  border: 1px #bababa dashed;
  float: left;
  margin-left: 30px;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 100px;
  height: 100px;
  line-height: 100px;
  text-align: center;
}
.avatar {
  width: 100px;
  height: 100px;
  display: block;
}
</style>